From 3b2cd972d5ae60f93b5aa1a97bd0c9dab7dd60cb Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 11 Nov 2020 17:43:44 +0000 Subject: [PATCH] a11y: Implement missing atspi.Component getters Some of them are entirely innocuous, and we can easily provide values that match what GTK3 provides. --- gtk/a11y/gtkatspicomponent.c | 19 ++++++++++++++++--- gtk/a11y/gtkatspiprivate.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/gtk/a11y/gtkatspicomponent.c b/gtk/a11y/gtkatspicomponent.c index 2ab1ffc81c..7da968d1d1 100644 --- a/gtk/a11y/gtkatspicomponent.c +++ b/gtk/a11y/gtkatspicomponent.c @@ -26,7 +26,9 @@ #include "gtkatspiprivate.h" #include "gtkatspiutilsprivate.h" #include "gtkaccessibleprivate.h" +#include "gtkpopover.h" #include "gtkwidget.h" +#include "gtkwindow.h" #include "a11y/atspi/atspi-component.h" @@ -194,11 +196,20 @@ component_handle_method (GDBusConnection *connection, } else if (g_strcmp0 (method_name, "GetLayer") == 0) { - g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, ""); + AtspiComponentLayer layer; + + if (GTK_IS_WINDOW (widget)) + layer = ATSPI_COMPONENT_LAYER_WINDOW; + else if (GTK_IS_POPOVER (widget)) + layer = ATSPI_COMPONENT_LAYER_POPUP; + else + layer = ATSPI_COMPONENT_LAYER_WIDGET; + + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", layer)); } else if (g_strcmp0 (method_name, "GetMDIZOrder") == 0) { - g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, ""); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(n)", 0)); } else if (g_strcmp0 (method_name, "GrabFocus") == 0) { @@ -206,7 +217,9 @@ component_handle_method (GDBusConnection *connection, } else if (g_strcmp0 (method_name, "GetAlpha") == 0) { - g_dbus_method_invocation_return_error_literal (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, ""); + double opacity = gtk_widget_get_opacity (widget); + + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(d)", opacity)); } else if (g_strcmp0 (method_name, "SetExtents") == 0) { diff --git a/gtk/a11y/gtkatspiprivate.h b/gtk/a11y/gtkatspiprivate.h index 9d3d316354..036a41ef27 100644 --- a/gtk/a11y/gtkatspiprivate.h +++ b/gtk/a11y/gtkatspiprivate.h @@ -252,4 +252,16 @@ typedef enum { ATSPI_COORD_TYPE_PARENT, } AtspiCoordType; +typedef enum { + ATSPI_COMPONENT_LAYER_INVALID, + ATSPI_COMPONENT_LAYER_BACKGROUND, + ATSPI_COMPONENT_LAYER_CANVAS, + ATSPI_COMPONENT_LAYER_WIDGET, + ATSPI_COMPONENT_LAYER_MDI, + ATSPI_COMPONENT_LAYER_POPUP, + ATSPI_COMPONENT_LAYER_OVERLAY, + ATSPI_COMPONENT_LAYER_WINDOW +} AtspiComponentLayer; + + G_END_DECLS -- 2.30.2